<div id="main_content" class="holidaywrap">
    <h3><?php echo $title ?></h3>  
    <div class="form_search wrapHoliday">
        <form method="POST" action="" name="frmHolidaySearch" class="frmHolidaySearch">
            <table width="400">
                <tr>
                    <td><?php echo $lblYear; ?></td>
                    <td>
                        <select name="cmbYear" class="cmbYear">
                            <option value="">--</option>
                            <?php if (count($cmbYear)): ?>
                                <?php foreach ($cmbYear as $item): ?>
                                    <option value="<?php echo $item->year; ?>" <?php echo($year == $item->year) ? 'selected' : ''; ?>><?php echo $item->year; ?></option>
                                <?php endforeach; ?>
                            <?php endif; ?>
                        </select>
                    </td>
                    <td><input type="button" value="<?php echo $lblSelect; ?>" class="btnSearch"/></td>
                </tr>
            </table>
        </form>
    </div>
    <div class="clr"></div>
    <a href="<?php echo base_url('/holiday/update'); ?>" class="new_regis"><?php echo $lblNewRegister; ?></a>
    <div class="table_list">
        <table border="0" width="500"  class="list_view_data salaryinfo" cellpadding="0" cellspacing="0">
            <tr align="center">
                <th><?php echo $lblOrder; ?></th>
                <th><?php echo $lblHolidayDate; ?></th>
                <th><?php echo $lblHolidayDescription; ?></th>
                <th><?php echo $lblHolidayAction; ?></th>
                <th><?php echo $lblHolidayActive; ?></th>
            </tr>
            <?php if ($data): ?>
                <?php foreach ($data as $item): ?>
                    <tr>
                        <td align="center" width="50"><?php echo ++$order; ?></td>
                        <td align="center" width="100"><?php echo date('Y/m/d', strtotime($item->Date)); ?></td>
                        <td align="center" width="350" title="<?php echo dQuotes($item->Description); ?>"><div class="table_col"><?php echo subString(dQuotes($item->Description), 50); ?></div></td>
                        <td align="center" width="75">
                            <div class="table_col">
                                <a data-HolidayID="<?php echo $item->HolidayID; ?>" href="<?php echo base_url('/holiday/update/'); ?>">
                                    <img src="<?php echo base_url('/public/sites/images/Pencil.png'); ?>" width="15">
                                </a>
                            </div>
                        </td>
                        <td align="center" width="70">
                            <img src="<?php echo ($item->Del_Flag) ? base_url('/public/sites/images/uncheck.gif') : base_url('/public/sites/images/check-icon.png'); ?>" width="15">
                        </td>
                    </tr> 
                <?php endforeach; ?>
            <?php endif; ?>
        </table>
        <?php if (!$data): ?>
            <div class="clr"></div>
            <div class="errormessage"><?php echo $message; ?></div>
        <?php endif ?>
    </div>
    <div class="clr"></div>
    <div class="pagination"><?php echo $pagi; ?></div>
</div>
<div class="redirectTo">
    <form class="frmRedirectTo" class="frmRedirectTo" name="frmRedirectTo" action="" method="POST">
        <input type="hidden" name="txtHolidayId" class="txtHolidayId" value="0">
    </form>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        $('.pagination a').click(function(e) {
            e.preventDefault();
            var url = $(this).attr('href');
            if (url != 'javascript:void(0)') {
                $('.frmHolidaySearch').attr('action', url);
                $('.frmHolidaySearch').submit();
            }
        });
        $('.btnSearch').click(function(e) {
            e.preventDefault();
            $('.frmHolidaySearch').attr('action', '/holiday');
            $('.frmHolidaySearch').submit();
        });
        /*change link action to post action*/
        $('.table_col a').click(function(e) {
            e.preventDefault();
            var url = $(this).attr('href');
            var holidayID = $(this).attr('data-HolidayID');
            $('.frmRedirectTo').attr('action', url);
            $('.txtHolidayId').val(holidayID);
            $('.frmRedirectTo').submit();
        });
    });
</script>